#include <REGX52.H>
#include "Delay.h"

sbit SER = P3^4; //SER 串行数据输入
sbit RCK = P3^5; //RCLK 上升沿锁存
sbit SCK = P3^6; //SERCLK 上升沿位移

/**
  * @brief  74HC595写入一个字节
  * @param  Byte 要写入的字节
  * @retval 无
  */
void _74HC595_WriteByte(unsigned char Byte)
{
	unsigned char i;
	for(i=0;i<8;i++)
	{
		//if(Byte&0x80){SER = 1;}else{SER = 0;}
		SER = Byte&(0x80>>i);//上述if可直接由此等式代替
		SCK = 1;
		SCK = 0;		
	}
	RCK = 1;
	RCK = 0;
}

/**
  * @brief  LED矩阵显示一列数据
  * @param  Column 要选择的列，范围：1~8，从左到右
  * @param  Data 选择列显示的数据，从高到低
	* @retval 无
  */
void MatrixLED_ShowColumn(unsigned char Column,Data)
{
	_74HC595_WriteByte(Data); //写入数据
	P0 = ~(0x80>>(Column-1)); //选择列
	Delay(1); //位延迟
	P0 = 0xFF;//位清零
}
void main()
{
	SCK = 0;
	RCK = 0;
	while(1)
	{
		MatrixLED_ShowColumn(1,0x30);
		MatrixLED_ShowColumn(2,0x78);
		MatrixLED_ShowColumn(3,0x3C);
		MatrixLED_ShowColumn(4,0x1E);
		MatrixLED_ShowColumn(5,0x1E);
		MatrixLED_ShowColumn(6,0x3C);
		MatrixLED_ShowColumn(7,0x78);
		MatrixLED_ShowColumn(8,0x30);
	}
}